const { ipcRenderer } = require("electron");
// 这里的@electron/remote就相当于main process
const { BrowserWindow } = require("@electron/remote");

document.addEventListener("DOMContentLoaded", () => {
  document.getElementById("node-version").innerHTML = process.versions.node;
  document.getElementById("send-main").onclick = () => {
    // 给主进程发送消息
    ipcRenderer.send("message", "from renderer");
    let win = new BrowserWindow({
      width: 800,
      height: 600,
    });
    win.loadURL("http://baidu.com");
  };
  // 监听消息
  ipcRenderer.on("reply", (e, arg) => {
    document.getElementById("message").innerHTML = arg;
  });
});
